<?php
namespace Gotcha\Core\Components\Debugging {
    use Gotcha\Core\Components\Debugging\Interfaces\IDebugger;
    use Gotcha\Core\Components\Debugging\Interfaces\ILogger;

    class Debugger implements IDebugger {
        protected $_ILogger;

        public function __construct(
            ILogger $ILogger
        ) {
            $this->_ILogger = $ILogger;
        }

        public static function Error($type, \Exception $ex, $logErrorYN = false, $killKernelYN = false)
        {
            if($logErrorYN) {
                Logger::Log($ex->getMessage(), $ex->getTraceAsString());
            }
            if($killKernelYN) {
                die();
            }
        }

        public static function XMLError($logErrorYN = false, $killKernelYN = false) {
            $xmlError = libxml_get_last_error();
            if($logErrorYN) {
                Logger::Log($xmlError->message, $xmlError->file);
            }
            if($killKernelYN) {
                die();
            }
            libxml_clear_errors();
        }
    }
}
